
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>写评价</title>
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_2825167_xauv9xekjqs.css">
    <script src="${pageContext.request.contextPath}/js/jquery-3.6.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/dist/layui/layui.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/dist/layui/css/layui.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/purchase_review.css">
</head>

<body>
<script src="${pageContext.request.contextPath}/js/purchase_review.js"></script>
<div class="wrap">
    <div class="brand">
        <ul>
            <li><a href="javascript:;">${vo.shop.shopCity}美食</a>></li>
            <li><a href="javascript:;">${vo.shop.shopLabel}</a>></li>
            <li><a href="javascript:;">${vo.shop.shopAdministrativeArea}</a>></li>
            <li><a href="javascript:;">${vo.shop.shopBusinessArea}</a>></li>
            <li><a href="javascript:;">${vo.shop.shopAddress}</a></li>
        </ul>
    </div>
    <div class="content">
        <div class="lef11">
            <div class="con1">
                <div class="con1-inner">
                    <p class="p1">${vo.shop.shopName} </p>
                    <div class="pj">
                        <div class="str"><span> </span><i>${vo.shop.shopScore}</i></div>
                        <p>${vo.shop.shopReviewAmount}条评价 人均：${vo.shop.shopAvgPrice}元 </p>
                    </div>
                    <p class="p2">地址： ${vo.shop.shopAdministrativeArea} ${vo.shop.shopBusinessArea}${vo.shop.shopAddress}</p>
                    <p class="p2">电话：${vo.shop.shopDetTelno}</p>
                </div>
                <div class="lookbox">

                    <a href="javascript:;" class="look2">查看商家详情</a>
                </div>
            </div>
            <div class="con2">
                <div class="incon2">
                    <p>我要评价</p>
                    <ul>
                        <li>
                            <div class="lef">
                                <span>总体评价</span>
                            </div>
                            <div class="rig">
                                <div id="zongti_score"></div>

                                <span class="score_value"></span>
                            </div>
                        </li>

                        <li>
                            <div class="lef">
                                <span>评价</span>
                            </div>
                            <div class="rig">
                                <div class="writebox">
                                        <textarea class="review_text" name=""  id="" cols="30"  rows="10">
                                        </textarea>

                                    <div class="bon">
                                        <img src="../images/evaluate_img/111.png" alt="">
                                        <span>15-2000个字</span>

                                    </div>
                                </div>
                            </div>
                        </li>
                        <li style="margin-top: 15px;">
                            <div class="lef">
                                <i>图片/视频</i>
                            </div>
                           <%-- <div class="rig22">
                                <p class="pa11">
                                    <input type="button" value="上传图片" class="pa11-img" onclick="openFile()">
                                    <input type="file" id="open" style="display: none">
                                    <i class="pa11-text">单张图片不超过10MB，尺寸不小于300*300px，支持jpg、png和bmp格式</i></p>
                               &lt;%&ndash; <p class="pa11">
                                    <input type="button" value="上传视频" class="pa11-img" onclick="openFile1()">
                                    <input type="file" id="open1" style="display: none">
                                    <i class="pa11-text">视频大小不得超过200M</i></p>&ndash;%&gt;
                            </div>--%>
                        </li>
                        <li>
                            <div class="lef">
                                <i>人均</i>
                            </div>
                            <div class="rig">
                                <p class="rj"><input type="text" class="avgPrice"> &nbsp元</p>
                            </div>
                        </li>
                    </ul>
                    <ul class="select">
                        <li class="select-list">
                            <dl id="select1">
                                <dt>喜欢的菜</dt>
                                <dd class="select-all selected"><a href="#">全部</a></dd>
                                <c:forEach var="dish" items="${vo.recommendedDishesList}">
                                    <dd>
                                       <input type="checkbox" name="dishName" class="dishName" value="${dish.recDishesName}"/>
                                    <a href="#">${dish.recDishesName}</a></dd>
                                </c:forEach>


                            </dl>
                        </li>


                    </ul>
                    <ul>
                        <li>
                            <div class="lef">

                            </div>
                            <div class="rig">
                                <p class="pj">
                                    评价和打分都将是其他网友的参考依据，并影响该商户评价。请发布真实、客观的本人消费体验评价。如您收到威逼、利诱如优惠等干扰而发布的评价或并非本人体验的虚假/恶意评价，则评价视为违规，同时影响您的信誉度。
                                </p>
                            </div>
                        </li>
                        <li>
                            <div class="lef">

                            </div>
                            <div class="rig ruy">
                                <div class="sav">

                                    <a href="javascript:;" class="saveReviewBtn abc2">发表评价</a>
                                </div>

                            </div>
                        </li>
                    </ul>
                    </ul>
                </div>
            </div>

        </div>
        <div class="rig11">
            <div class="con1">
                <h2>附近商户推荐</h2>
                <div class="shopbox">
                    <ul>
                        <li>
                            <div class="lef2">
                                <img src="../images/purchase_review_img/rig-1.png"
                                     alt="">
                            </div>
                            <div class="rig2">
                                <p class="p1">水宴会餐厅(明月湾店) <span class="ding">订</span> <span class="tuan">团</span>
                                </p>
                                <p class="p2"><i></i></p>
                                <p class="p3"><span>太湖西山</span> <span>人均￥441</span> </p>
                            </div>
                        </li>
                        <li>
                            <div class="lef2">
                                <img src="../images/purchase_review_img/rig-2.png"
                                     alt="">
                            </div>
                            <div class="rig2">
                                <p class="p1">缘庭拙朴·蔡巷农家乐 <span class="ding">订</span> <span class="tuan">团</span>
                                </p>
                                <p class="p2"><i></i></p>
                                <p class="p3"><span>太湖西山</span> <span>人均￥441</span> </p>
                            </div>
                        </li>
                        <li>
                            <div class="lef2">
                                <img src="../images/purchase_review_img/rig-3.png"
                                     alt="">
                            </div>
                            <div class="rig2">
                                <p class="p1">灿然雅悦<span class="tuan">团</span> </p>
                                <p class="p2"><i></i></p>
                                <p class="p3"><span>太湖西山</span> <span>人均￥441</span> </p>
                            </div>
                        </li>
                        <li>
                            <div class="lef2">
                                <img src="../images/purchase_review_img/rig-4.png"
                                     alt="">
                            </div>
                            <div class="rig2">
                                <p class="p1">抱朴乡居•岭下 </p>
                                <p class="p2"><i></i></p>
                                <p class="p3"><span>太湖西山</span> <span>人均￥441</span> </p>
                            </div>
                        </li>
                        <li>
                            <div class="lef2">
                                <img src="../images/purchase_review_img/rig-1.png"
                                     alt="">
                            </div>
                            <div class="rig2">
                                <p class="p1">逸辰别院民宿·餐厅(西山店) <span class="tuan">团</span> </p>
                                <p class="p2"><i></i></p>
                                <p class="p3"><span>太湖西山</span> <span>人均￥441</span> </p>
                            </div>
                        </li>
                    </ul>
                    <p class="lokmore">
                        <a href="javascript:;">查看更多</a>
                        <span>></span></span>
                    </p>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${pageContext.request.contextPath}/js/purchase_review.js"></script>

<script>

        layui.use(['rate'], function(){
        var rate = layui.rate;
        rate.render({
        elem: '#zongti_score'
        ,value: 0
        ,half: true
        ,text: true
        ,setText: function(value){
            this.span.text(value);
         }
         });
    });

        var zongti_score = 0;
        //获得评分的值
        $("#zongti_score").click(function(){
            $(".score_value").text("");

            zongti_score = $("#zongti_score span").text();
            console.log("zongti_score="+zongti_score)
            $("#zongti_score span").text(zongti_score+"星")
        })

        /*submit new review */
        $(".saveReviewBtn").click(function (){
            // shopid , custId,list[dishId],score,text
            var shopId = '${vo.shop.shopId}';
            var reviewScore = zongti_score;
            var reviewText = $(".review_text").val().trim();
            var avgPrice = $(".avgPrice").val();

            var dishes = $("input[name='dishName']");
            console.log("selected dish size:" +dishes.length);
            var dishNames = "";

            for(var i =0;i<dishes.length;i++){
                if(dishes[i].checked){
                    console.log("selected dish name:" + dishes[i].value);
                    dishNames+=dishes[i].value +",";
                }
            }
            console.log("shopId ="+shopId)
            console.log("reviewScore ="+reviewScore)
            console.log("reviewText ="+reviewText)
            console.log("avgPrice ="+avgPrice)
            console.log("dishNames ="+dishNames)


            var data = {
                 shopId:shopId,
                 reviewScore:reviewScore,
                 reviewText: reviewText,
                 avgPrice:avgPrice,
                 dishNames:dishNames
            }

            var url = '${pageContext.request.contextPath}'+"/review";
            console.log("url ="+url)
            console.log("data ="+data)

             $.post(
                 url,
                 data,
                function (result){
                    console.log("result:" + result);
                    location.href='${pageContext.request.contextPath}'+"/shop/"+shopId;
                },
                "json"

            )

        })

</script>
</body>
</html>
